package com.supermap.application.controller;

import com.supermap.application.common.Region;
import com.supermap.application.entity.TRegioninfo;
import com.supermap.application.service.RegionInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName RegionCatalogsController
 * @Description TODO
 * @Author HEKE
 * @Date 2019/2/26 15:00
 */

@Controller
@RequestMapping(value = {"/data","/data/macro"})
public class RegionCatalogsController {


    @Autowired
    private RegionInfoService regionInfoService;


    @RequestMapping(value="/regionCatalogs/{catalogid}/selregions", method = RequestMethod.GET)
    @ResponseBody
    public List<TRegioninfo> findSelRegions(@PathVariable("catalogid") int catalogid, int level , @RequestBody Region[] regions){
        List<TRegioninfo> re = regionInfoService.findSelRegions2(catalogid,regions,level);
        if(re == null) {
            re = new ArrayList<TRegioninfo>();
        }
        for (int i = 0; i<re.size();i++){
            TRegioninfo tRegioninfo = re.get(i);
            System.out.println(tRegioninfo);
        }
        return re;
    }
}
